You should wait a minimum of 30 minutes to workout after you eat because if you workout sooner than 30 minutes after eating you can feel sluggish and may even experience cramps.
That same thing goes for swimming you should wait 20 to 30 minutes after eating before going swimming to avoid cramps and other other problems.
The longer you wait the better but as long as you're waiting 30 minutes before your workout after eating then you'll be fine.
So allow yourself at least 30 minutes to eat beforehand before your workout begins.