Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Check second method invoked before first finished  RSS feed

 
Daniel Stankiewicz
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've got two methods m1() and m2(). m2() is a callback method of a listener, that I implement by myself. m1() is a method, that I don't know implementation, but according to API it is said, that m2() MUST be invoked BEFORE m1() finishes. How can I check if this method was really invoked BEFORE?...

Thanks in advance for helping
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Daniel]: according to API it is said, that m2() MUST be invoked BEFORE m1() finishes.

That's an odd requirement. If you don't have access to the m1() source and can't edit it, then I'm pretty sure the only way to make sure m1() doesn't finish before m2() is to make sure it doesn't start before m2(). The easiest way to do that is to make sure that both methods are called from the same thread, and m2() is called before m1(). I can't see any way to really take advantage of concurrency here and still enforce the requirement from the API.
 
Daniel Stankiewicz
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a bit different case. According to API method m1() must invoke m2() inside its body, and I'm going to write tests that will check if m2() was invoked inside m1()...
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In that case, does the test need to invovle multiple threads at all? If you're calling m2() from m1(), then m2() is being run by the same thread as m1(). You can just write the test using one thread, yes? This seems like a testing question rather than a threads question. Should we move the topic, or are there other details that explain why it was posted here?
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!